How to configure XML Feed

If you select XML file type at tab Content Settings you can create/edit xml schema for your feed. By default we provide templates for XML feeds, so you can easily copy it and change for your requirements.

Usually Comparison Shopping Engines provide a template of the xml file. Based on this template, you can create own xml schema.

Typical xml schema:

<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
    {each type="product"}
      <item>
        <attribute_1><![CDATA[{attribute_1}]]></attribute_1>
        <attribute_2><![CDATA[{attribute_2}]]></attribute_2>
        .....
      </item>
    {/each}
</rss>

Product cycle block:

{each type="product"}
    ...
{/each}

Inside this block, you can use any product attribute.

Category cycle block:

{each type="category"}
    ...
{/each}

Inside this block, you can use any category attribute.

Review cycle block:

{each type="review"}
    ...
{/each}

Inside this block, you can use any review attribute.

Attribute (pattern) block:

<attribute_1><![CDATA[{attribute_1}]]></attribute_1>

The attribute code must be enclosed in curly brackets: {attribute_code}. You can use all attribute codes available at Catalog > Manage Attributes and all static attributes (ex. entity_id, created_at etc).

Additionaly in curly brackets you can place any avalilable pattern. Full pattern list of patterns

Characters like < and & are illegal in XML elements.

  • < will generate an error because the parser interprets it as the start of a new element.
  • & will generate an error because the parser interprets it as the start of an character entity.

We suggest enclosed all patterns in CDATA block <attribute><![CDATA[{pattern}]]></attribute>. In this case, xml data feed will be valid.


Google Shopping Feed Example

Lets check example of the Google Shopping template.
We created the XML template using Google Shopping guide: https://support.google.com/merchants/answer/160589?hl=en&ref_topic=2473799
google_template.png

Lets check next tag lines.


At these lines sets xml encoding format: utf-8, sets RSS 2.0 format of the feed template and Google namespace declaration (xmlns:g=).
google2.png


Here you can set three pre-defined elements which describe feed general information - title, link, and description.
google3.png


Between tags <item> ... </item> must be used attributes which response for product values. To make extension export all products from the store, we covered tags <item> ... </item> with Product cycle block: {each type="product"} ... {/each} google4.png


Lets check how we can use store attributes at the feed template.

At this page you can see attributes that you can use the template and accepted values https://support.google.com/merchants/answer/188494?hl=en
All attributes and patterns must be covered by curly brackets {}, otherwise extension will not export attribute values: {sku},{image},etc.
Tags <g:item_group_id> Google uses to declare product variations( configurable/grouped/bundled products). It means that here must be set value of the parent product. Extension allows to export product variation. You can use suffix |parent to return value of parent product. For example: {desciption|parent}, {image|parent}, etc. As rule, uses SKU do declare parent products, thats why we used this attribute: {sku|parent}. Also we set |parent suffix for URL attribute to combine all child products in to the one product link.
You can use a lot of patterns with attributes:
<description><![CDATA[{description,[strip_tags],[substr 0 1000]}]]></description> - at this line used strip_tags to delete all html tags from the feed and substr set max string lenght 1000 chars.
<g:price>{price,[number_format 2]}</g:price> - sets max 2 numbers for a price after comma

At the tags <g:google_product_category>...</g:google_product_category> Google recommend to set their own category names for the products, which mostly differ from the merchant stores. Extension allows easily replace in the feed store categories to the Google categories by creating Category mapping attribute. At this template it is declared as {mapping:1}, where 1 is a category mapping attribute id. For more information how to create and use it, check Category Mapping
Extension allows to use Dynamic Attributes when basic attributes require some improvements. For example, Google accept only one of these three values for gender: male, female, unisex. Merchant store may have another values for gender, so dynamic attributes can solve this and other tasks. Prefix custom: must be set before dynamic attribute name: {custom:google_gender}. For more information, see Dynamic attributes

google5.png


Advanced Product Feeds